package com.lanchetech.entity;


import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import lombok.Getter;

public class WithdrawStatusConverter implements Converter<Integer> {
    @Getter
    public enum WithdrawStatusEnum {
        FAIL(0, "提现失败"),
        SUCCESS(1, "提现成功"),
        PROCESSING(2, "提现中"),
        REFUSE(3, "拒绝提现"),
        ;

        private Integer status;
        private String remark;

        WithdrawStatusEnum(Integer status, String remark) {
            this.status = status;
            this.remark = remark;
        }

        public static WithdrawStatusEnum getByStatus(Integer status) {
            for (WithdrawStatusEnum item : WithdrawStatusEnum.values()) {
                if (item.getStatus().equals(status)){
                    return item;
                }
            }
            return null;
        }
    }

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData convertToExcelData(Integer status, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new CellData(WithdrawStatusEnum.getByStatus(status).getRemark());
    }
}
